﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using syh876.com.Models;
using System.Data;
using syh876.com.Areas.User.Code;
using Common;
using SYH.Utils;
using System.Text;


namespace syh876.com.Controllers
{
    public class AccountController : Controller
    {
        //
        // GET: /Account/
        /// <summary>
        /// 登录
        /// </summary>
        public ActionResult Login()
        {
            //this.TempData["rel"] = this.TempData["rel"] ?? Request.UrlReferrer;
            return View();     
         
        }

        //[HttpPost]
        //public ActionResult Index()
        //{

        //    string accountName = Common.RequestHelper.GetString("txtUserName").Trim();
        //    string password = Common.RequestHelper.GetString("txtPwd").Trim();
        //    string verifyCode = Common.RequestHelper.GetString("txtCode").Trim();
        //    int isRemember = Common.RequestHelper.GetInt("rememberMe", 0);
        //    SYH.User.Model.UserSimplyInfo usmodel = new SYH.User.Model.UserSimplyInfo();
            
        //    if (String.Equals(Session["CheckCode"].ToString().ToLower(), verifyCode.ToLower()))
        //    {
        //        ViewData["errorMsg"] = "验证码错误！请重新输入";
        //        return View();
        //    }
           
        //    else
        //    {
        //        usmodel = SYH.User.BLL.UserSimplyInfo.CheckLogin(accountName, password);
        //        if (usmodel == null )
        //        {
        //             ViewData["errorMsg"] = "用户名或密码错误！请重新输入";
        //             return View();
        //        }
        //        else if (usmodel.Status<0)
              
        //        {
        //            ViewData["errorMsg"] = "该用户已被禁止；请联系管理员";
        //            return View();
        //        }
        //        else
        //        {
        //            return RedirectToAction("Index", "Home");
        //        }
                
        //    }    
          
        //    string IdType = User_Manager.GetUserType(result);
        //    if (result > 0 || result == -1)
        //    {
        //        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
        //                                                                         result.ToString(),
        //                                                                         DateTime.Now,
        //                                                                         DateTime.Now.AddHours(1),
        //                                                                         true,
        //                                                                         IdType);
        //        //加密票据
        //        string authTicket = FormsAuthentication.Encrypt(ticket);
        //        //存储为cookie
        //        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, authTicket);
        //        //cookie.Domain = "oa.qihuiwang.com";
        //        cookie.Expires = ticket.Expiration;
        //        Response.Cookies.Add(cookie);
        //        //Session.Add("loginName", loginName);
        //        if (Session["Code"].ToString().ToLower() != code.ToLower())
        //        {
        //            ViewData["errorMsg"] = "验证码错误！请重新输入";
        //            return View();
        //        }
        //        else
        //        {
        //            return RedirectToAction("Index", "Home");
        //        }
        //        //return RedirectToAction("Index", "Home");
        //    }
        //    else
        //    {
        //        ViewData["errorMsg"] = "用户名或密码错误！";
        //        return View();
        //    }
        //}


        /// <summary>
        /// 用户注册 （邮箱验证）
        /// </summary>
        ///
        public ActionResult Register()
        {
            //用户注册时选择一级行业分类
            DataTable Public_IndustriesDT = null;
            //if (Common.DotNetCacheManager.Get("Public_IndustriesDT") == null)
            //{
            //    Public_IndustriesDT = SYH.Product.BLL.Industry.GetList(0);
            //    Common.DotNetCacheManager.Add("Public_IndustriesDT", Public_IndustriesDT, 10);
            //}
            //else
            //{
            //    Public_IndustriesDT = Common.DotNetCacheManager.Get("Public_IndustriesDT") as DataTable;
            //}
            Public_IndustriesDT = SYH.Product.BLL.Industry.GetList(0);
            ViewBag.Public_IndustriesDT = Public_IndustriesDT;
            return View();
        }

        /// <summary>
        /// 退出
        /// </summary>
        public ActionResult Logout()
        {
            IdentityHelper.LoginOut();
            return View();
            
        }
        /// <summary>
        /// 重置密码
        /// </summary>
        public ActionResult ResetPwd()
        {
            return View();
        }
    }
}
